﻿using Asp.Versioning;
using Microsoft.AspNetCore.Mvc;
using SimpleTicketBooking.Controllers.Base;
using SimpleTicketBooking.Models;
using SimpleTicketBooking.Models.Query;
using SimpleTicketBooking.Utils.Ext;

namespace SimpleTicketBooking.Controllers
{
    /// <summary>
    /// User resoureces
    /// </summary>
    [ApiVersion((double)ApiVersions.V1)]
    [ApiExplorerSettings(IgnoreApi = false, GroupName = nameof(ApiVersions.V1))]
    [ApiController]
    [Route("api/[controller]/v{version:apiVersion}/[action]")]
    public class UserController : APIControllerBase
    {
        private readonly ILogger<UserController> _logger;

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="logger"></param>
        public UserController(ILogger<UserController> logger)
        {
            _logger = logger;
        }

        /// <summary>
        /// Get User by Id
        /// </summary>
        /// <param name="Id">User Id</param>
        /// <returns></returns>
        [HttpGet]
        public User GetById(int Id) 
        {
            return new User() { Name="leezt", Id=1};
        }

        /// <summary>
        /// Get all users
        /// </summary>
        /// <param name="pageQuery"></param>
        /// <returns></returns>
        [HttpGet(Name ="users")]
        public IEnumerable<User> GetAll([FromQuery]PageQuery pageQuery)
        {
            return new List<User>() { };
        }

        /// <summary>
        /// update user info
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPut]
        public bool Update([FromBody]User user)
        {
            return true;
        }

        /// <summary>
        /// Add new user
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        [HttpPost]
        public bool Add([FromBody] User user)
        {
            return true;
        }

        /// <summary>
        /// Delete by Id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpDelete]
        public bool Delete(int Id)
        {
            // TODO: validate input parameters

            // perform logical deletion
            return true;
        }
    }
}
